package com.cj.exception;


import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.cj.vo.JsonResult;

@RestControllerAdvice
public class GlobalExceptionHandler{
	
	// 处理运行时异常
	@ExceptionHandler(RuntimeException.class)
	public JsonResult doHandleRunTimeException(RuntimeException r) {
		r.printStackTrace();
		JsonResult js = new JsonResult();
		js.setState(0);
		js.setMessage("运行时发生错误,请稍等片刻!");
		return js;
	}
	
	// 处理业务层异常
	@ExceptionHandler(ServiceException.class)
	public JsonResult doHandleServiceException(ServiceException s) {
	    s.printStackTrace();
		return new JsonResult(s);
	}
	
	
	
}
